import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

df = pd.read_excel('餐厅订单信息.xlsx')
plt.rcParams['font.sans-serif'] = 'SimHei'
#绘制各分店不同星级会员消费金额柱状图
plt.figure()
width = 0.15
i = 0
x = np.arange(3)

groups = df.groupby('店铺名')
shop_name = []
for group in groups:
    shop_name.append(group[0])
    df_temp = pd.DataFrame(group[1])

    df_temp = df_temp.groupby('会员星级').agg('sum', numeric_only=True)
    height = df_temp['消费金额']
    plt.bar(x + width * i, height, width)
    i += 1
plt.legend(shop_name)
plt.xlabel('会员星级')
plt.ylabel('消费金额（元）')
plt.xticks(range(3), df_temp.index)
plt.title('各分店不同星级会员消费金额柱状图')